package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhBaseinfoArchives;
import com.yinhe.system.service.IYhBaseinfoArchivesService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 办公设备Controller
 * 
 * @author yinhe
 * @date 2022-07-13
 */
@RestController
@RequestMapping("/system/archives")
public class YhBaseinfoArchivesController extends BaseController
{
    @Autowired
    private IYhBaseinfoArchivesService yhBaseinfoArchivesService;

    /**
     * 查询办公设备列表
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhBaseinfoArchives yhBaseinfoArchives)
    {
        startPage();
        List<YhBaseinfoArchives> list = yhBaseinfoArchivesService.selectYhBaseinfoArchivesList(yhBaseinfoArchives);
        return getDataTable(list);
    }

    /**
     * 导出办公设备列表
     */
    @PreAuthorize("@ss.hasPermi('system:archives:export')")
    @Log(title = "办公设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhBaseinfoArchives yhBaseinfoArchives)
    {
        List<YhBaseinfoArchives> list = yhBaseinfoArchivesService.selectYhBaseinfoArchivesList(yhBaseinfoArchives);
        ExcelUtil<YhBaseinfoArchives> util = new ExcelUtil<YhBaseinfoArchives>(YhBaseinfoArchives.class);
        util.exportExcel(response, list, "办公设备数据");
    }

    /**
     * 获取办公设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:archives:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhBaseinfoArchivesService.selectYhBaseinfoArchivesById(id));
    }

    /**
     * 新增办公设备
     */
    @PreAuthorize("@ss.hasPermi('system:archives:add')")
    @Log(title = "办公设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhBaseinfoArchives yhBaseinfoArchives)
    {
        return toAjax(yhBaseinfoArchivesService.insertYhBaseinfoArchives(yhBaseinfoArchives));
    }

    /**
     * 修改办公设备
     */
    @PreAuthorize("@ss.hasPermi('system:archives:edit')")
    @Log(title = "办公设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhBaseinfoArchives yhBaseinfoArchives)
    {
        return toAjax(yhBaseinfoArchivesService.updateYhBaseinfoArchives(yhBaseinfoArchives));
    }

    /**
     * 删除办公设备
     */
    @PreAuthorize("@ss.hasPermi('system:archives:remove')")
    @Log(title = "办公设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhBaseinfoArchivesService.deleteYhBaseinfoArchivesByIds(ids));
    }
}
